package org.noworks.game;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;
import org.noworks.game.engine.RenderComponent;

public class ImageRender extends RenderComponent {

	private Image image; // Image to render
	private float scale;

	public ImageRender(String filename, String id, float scale) throws SlickException {
		super(id);
		image = new Image(filename);
		this.scale = scale;
	}

	public ImageRender(String filename, String id) throws SlickException {
		super(id);
		image = new Image(filename);
	}

	public int getHeight() {
		return (int) (image.getHeight() * scale);
	}

	public int getWidth() {
		return image.getWidth();
	}

	@Override
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g) {
		Vector2f p = owner.getPosition();
		image.draw(p.x, p.y, owner.getScale() * scale);
	}

	@Override
	public void update(GameContainer gc, StateBasedGame sbg, int delta) {

	}

}
